package com.design.boot.controller;

import com.design.boot.model.User;
import com.design.boot.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.jws.soap.SOAPBinding;

/**
 * @author kakayubei
 * @description
 * @date 2021/7/29 1:46
 */
@Controller
@Slf4j
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;
    @RequestMapping("/getAll.html")
    public String getUsers(Model model) {
        model.addAttribute("users", userService.getAllUser());
        return "user.html";
    }

    @RequestMapping("/getUser/{id}")
    @ResponseBody
    public User getUSer(@PathVariable Long id) {
        return userService.selectByPrimaryKey(id);
    }

//    @RequestMapping("/getAll.jsp")
//    public String getUsersJsp(Model model) {
//        model.addAttribute("users", userService.getAllUser());
//        return "user.jsp";
//    }
}
